import 'dart:typed_data';

import 'package:flutter/cupertino.dart';

import 'flutter_text_reader_platform_interface.dart';

typedef MethodHandler = Future<dynamic> Function(String method, Map<String, dynamic> param);

class FlutterTextReaderWidgetController extends ChangeNotifier {
  FlutterTextReaderWidgetController({required this.id}) {
    s_controllers[id] = this;
  }
  static final s_controllers = Map<int, FlutterTextReaderWidgetController>();

  int id;
  MethodHandler? handler;

  load(String path, bool isHor) async {
    return await FlutterTextReaderPlatform.instance.load(path, isHor);
  }

  setMethodHandler(MethodHandler handler) {
    this.handler = handler;
  }

  @override
  void dispose() {
    s_controllers.remove(id);
    super.dispose();
  }
}